<!--
  * 供应商下拉选择框
-->
<template>
  <a-select :options="list" />
</template>

<script setup lang="ts">
import { searchApi } from '@/api/search/search-api'
const props = defineProps({
  fetchParams: {
    type: Object,
    default: () => ({})
  }
})
// =========== 查询数据 =============
const list = shallowRef([])
async function queryList(fetchParams?: any) {
  const params = fetchParams ?? props.fetchParams
  const res = await searchApi.supplierList(params)
  list.value = res.data.map((item) => {
    return {
      ...item,
      label: item.name,
      value: item.id
    }
  })
}
onMounted(queryList)
defineExpose({
  queryList
})
</script>
